<form class="form-horizontal" name="type_form" ng-submit="do_upsert()">
    <div class="modal-header">
        <a class="close" ng-click="close()">&times;</a>

        <div class="input-prepend input-append">
            <h4>配置网络</h4>
        </div>
    </div>
    <div class="modal-body">
        <div class="control-group">
            <label for="name" class="control-label">名称：</label>

            <div class="controls">
                <input type="text" required ng-model="network.name" class="input" ng-disabled="update"  ng-pattern="/^\w+$/"/>
            </div>
        </div>
        <div class="control-group">
            <label for="name" class="control-label">网络类型：</label>

            <div class="controls">
                <select ng-model="network.networktype" required ng-change="select_network()" ng-disabled="update">
                    <option value="0">NAT</option>
                    <option value="1">隔离</option>
                    <option value="2">桥接</option>
                    <option value="3">vlan</option>
                </select>
                <span style="padding-left: 10px">组播探测：<input type="checkbox" ng-model="network.cast_snoop"/></span>

            </div>

        </div>
        <div class="control-group" ng-show="network.networktype==2||network.networktype==3">

        </div>
        <div class="control-group" ng-show="network.networktype==3">
            <label for="name" class="control-label">VLAN ID：</label>

            <div class="controls">
                <input type="text" class="input-mini" ng-required="network.networktype==3" ng-model="network.vlanid" ng-disabled="update"/>
            </div>
        </div>
        <!--<div class="control-group">
            <label for="name" class="control-label">IP网段：</label>

            <div class="controls">
                <input type="text" required ng-model="network.cidr" class="input"/>
                <label>提示：通常来说应该填写ipv4专用地址，例如：192.168.0.0/24, 10.0.0.0/24</label>
                <table class="table table-bordered table-condensed">
                    <tr>
                        <th>子网掩码</th>
                        <th>广播地址</th>
                        <th>网关</th>
                        <th>数量</th>
                        <th>类型</th>
                    </tr>
                    <tr>
                        <td>255.255.255.0</td>
                        <td>172.16.10.255</td>
                        <td>172.16.10.1</td>
                        <td>256</td>
                        <td>C类地址</td>
                    </tr>
                </table>
            </div>
        </div>-->
        <div class="control-group" ng-show="network.networktype!=0" >
            <label for="name" class="control-label">启用DHCP：</label>

            <div class="controls">
                <input type="checkbox" class="input-mini" ng-model="network.rundhcp"/>
            </div>
        </div>
        <div class="control-group">
            <label for="name" class="control-label">DHCP开始：</label>


            <div class="controls">
                <input type="text" ng-required="network.rundhcp||network.networktype==0" ng-model="network.dhcp_start" class="input"
                       ng-disabled="!network.rundhcp"/>
                <label>提示：通常来说应该填写ipv4专用地址，例如：192.168.0.100, 10.0.0.100</label>
            </div>
        </div>
        <div class="control-group">
            <label for="name" class="control-label">DHCP结束：</label>

            <div class="controls">
                <input type="text" ng-required="network.rundhcp||network.networktype==0" ng-model="network.dhcp_end" class="input"
                       ng-disabled="!network.rundhcp"/>
            </div>
        </div>
        <div class="control-group">
            <label for="name" class="control-label">子网掩码：</label>

            <div class="controls">
                <input type="text" ng-required="network.rundhcp||network.networktype==0" ng-model="network.netmask" class="input"
                       ng-disabled="!network.rundhcp"/>
            </div>
        </div>

        <div class="control-group" ng-show="network.networktype==2||network.networktype==3">
            <label for="name" class="control-label">网关：</label>

            <div class="controls">
                <input type="text" ng-model="network.gateway" class="input" ng-disabled="!network.rundhcp"/>
            </div>
        </div>
        <div class="control-group" ng-show="network.networktype==2||network.networktype==3">
            <label for="name" class="control-label">DNS1：</label>

            <div class="controls">
                <input type="text" ng-model="network.dns1" class="input" ng-disabled="!network.rundhcp"/>
            </div>
        </div>
        <div class="control-group" ng-show="network.networktype==2||network.networktype==3">
            <label for="name" class="control-label">DNS2：</label>

            <div class="controls">
                <input type="text" ng-model="network.dns2" class="input" ng-disabled="!network.rundhcp"/>
            </div>
        </div>
        <!--<div class="control-group">
            <label for="name" class="control-label">目标设备：</label>

            <div class="controls">
                <select ng-model="vm.host" ng-options="h.name for h in cluster.hosts" class="span2">
                    <option value="">任意</option>
                </select>
            </div>
        </div>-->
        <div class="control-group">
            <label for="name" class="control-label">关联集群：</label>

            <div class="controls">
                <select ng-options="c.name for c in clusters" required ng-model="network.cluster" ng-disabled="update">

                </select>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <span style="padding-right: 230px;color: red;" ng-show="error">{{ error }}</span>
        <a data-dismiss="modal" class="btn" ng-click="close()">关闭</a>

        <button type="submit" ng-disabled="!type_form.$valid" class="btn btn-primary">保存</button>
    </div>
</form>